var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, o) {
    var a, r = arguments.length, s = r < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, n, o); else for (var i = t.length - 1; 0 <= i; i--) (a = t[i]) && (s = (r < 3 ? a(s) : 3 < r ? a(e, n, s) : a(e, n)) || s);
    return 3 < r && s && Object.defineProperty(e, n, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameData"), s = e("DataManager"), c = e("EggsManager"), l = e("UIManager"), d = e("WebManager"), u = e("Global"), p = e("PersonView"), h = cc._decorator, f = h.ccclass, g = h.property, m = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.personView = null, t.count = 0, t.total = 10, t.count2 = 0, t.total2 = 10, 
        t.idx = 9, t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        -1 == c.default.getInstance().checkEggGun(this.idx) ? (this.init(), this.node.on("follow_success", this.doReward, this)) : this.node.destroy();
    }, t.prototype.onDestroy = function() {
        cc.systemEvent.off("toggle_gun_skin", this.doRefresh, this);
    }, t.prototype.start = function() {}, t.prototype.init = function() {
        cc.systemEvent.on("toggle_gun_skin", this.doRefresh, this);
    }, t.prototype.doRefresh = function(t) {
        var e = this;
        this.count < this.total && 48 == t && this.count++, this.count == this.total && this.count2 < this.total2 && (46 == t && this.count2++, 
        this.count2 == this.total2) && (!GA.isPlatform([ GA.Platform.ByteDance, GA.Platform.Kwaigame ]) || r.GD.isFollow ? this.doReward() : l.default.getInstance().loadPnl("eggsTips").then(function(t) {
            t && (t.target = e.node);
        }));
    }, t.prototype.doReward = function() {
        d.default.getInstance().sentLog("获得武器彩蛋id:" + this.idx), c.default.getInstance().updateEggGun(this.idx);
        var t = c.default.getInstance().getDataGun(this.idx);
        t && (t.time = Date.now(), c.default.getInstance().setDataGun(this.idx, t)), r.GD.gunIdx = this.idx + 1e3, 
        this.personView.changeGun(r.GD.gunIdx);
        var e = l.default.getInstance().getPnl("start"), t = e.boxs.filter(function(t) {
            return t.isEmpty();
        });
        0 < t.length ? (e.appendItem(r.GD.gunIdx, t[0]), e.updateMatrix()) : e.appendEquip(r.GD.gunIdx), 
        s.default.getInstance().save(), l.default.getInstance().loadPopPnl("egg_reward", {
            type: u.RewardType.ARM,
            idx: r.GD.gunIdx,
            scale: 1.6
        }), cc.systemEvent.off("change_gun_skin", this.doRefresh, this);
    }, a([ g(p.default) ], t.prototype, "personView", void 0), a([ f ], t);
}(cc.Component);

n.default = m;